****************************************************
*** TABLE 2: Dynamic Effect of Hearings on IP Rate.
****************************************************

use "$DATALOC/AgencyLevel.dta", clear
eststo a1_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo a1_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government
eststo a1_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace

use "$DATALOC/ProgramLevel.dta", clear
eststo p1_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo p1_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(programname FY) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government.
eststo p1_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(programname FY) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace

*** OUTPUT TABLE
esttab a1_1 a1_3 a1_2 p1_1 p1_3 p1_2 using "$TABLELOC/Table02.tex", ///
	prehead("\begin{table}[htbp]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Dynamic Effect of Hearings on Improper Payment Rate. Dependent variable is improper payment rate as a percent of all payments.} \resizebox{\textwidth}{!}{ \begin{tabular}{l*{7}{c}} \toprule") ///
	b(a2) fragment ///
	booktabs label se star(** 0.05 *** 0.01)s(fixedyear fixedagency N, label("Fiscal Year FE" "Agency/Program FE" "Observations")) ///
	order(last_agen_hear last_agenXuni last_agen_hear_h last_agen_hear_s agen_hear_all agen_hearXuni agen_hear_h agen_hear_s ) keep(agen* last*) ///
	nomtitles ///
	mgroups("Agency-level" "Program-level", ///
				pattern(1 0 0 1 0 0) ///
				span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	prefoot("\hline") ///
	postfoot("\bottomrule \multicolumn{7}{l}{\footnotesize Standard errors in parentheses; clustered on agency-year for program-level analysis.}\\ \multicolumn{4}{l}{\footnotesize \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\ \end{tabular} } \\ \label{tab:dynamic} \end{table}") replace


